package com.zhangmeng.online.exam.entity;

import com.zhangmeng.online.exam.entity.baseEntity.BaseEntity;
import lombok.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zm
 * @date 2025/2/28 16:06
 * @version: 1.0
 */
@NoArgsConstructor
@Data
@ToString(exclude = {"options", "subject", "papers"})
@AllArgsConstructor
@Entity
@EqualsAndHashCode(callSuper = false)
@Table(name = "question")
public class Question extends BaseEntity<Long> {

    public enum Type {
        SINGLE_CHOICE("单选题", 0),//单选题
        MULTIPLE_CHOICE("多选题", 1),//多选题
        JUDGMENT("判断题", 2),//判断题
        SHORT_ANSWER("简答题", 3),//简答题
        Fill_IN_THE_BLANKS("填空题", 4),//填空题
        NUMERICAL("计算题",5);//计算题

        private String desc;

        private int index;

        Type(String desc, int index) {
            this.desc = desc;
            this.index = index;
        }

        Type(String desc) {
            this.desc = desc;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }
    }

    private String name;

    private Type type;

    private Integer score;//分值

    private String explanation;//问题解析

    @OneToMany(mappedBy = "question")
    private List<QuestionOption> options = new ArrayList<>();

    @ManyToOne(fetch = FetchType.LAZY)
    private Subject subject;

    @ManyToMany(mappedBy = "questions",targetEntity = Paper.class)
    private List<Paper> papers = new ArrayList<>();
}
